<%@codepage="65001"%>
<%session.codepage="65001"%>
<!-- #include virtual=/inc/dbConn.asp -->
<!-- #include virtual=/inc/function.asp -->
<!-- #include virtual=/inc/action.header.inc.asp -->

<%
	'## 파라미터 변수 선언부
	fullLotNo		= Request("lotNo")
	lotSubNo		= Request("lotSubNo")
	processCd		= Request("processCd")
	rank				= Request("rank")
	workDt			= Request("workDt")
	startDt			= Request("startDt")
	endDt			= Request("endDt")
	working			= Request("working")
	execTime		= Request("execTime")
	etc				= Request("etc")
	goodQty		= Request("goodQty")
	badQty			= Request("badQty")
	totalQty		= Request("totalQty")
	orderMemo	= Request("orderMemo")
	userId			= Request("userId")
	flag				= Request("flag")

	If lotSubNo = "" Then lotSubNo = "0" End If 
	If goodQty = "" Then goodQty = "0" End If 
	If badQty = "" Then badQty = "0" End If 
	If totalQty = "" Then totalQty = "0" End If 
	
	lotYear = left(fullLotNo,2)
	lotNo = right(fullLotNo,4)

	orderMemo		= Replace(orderMemo,"'","''")
	
	if startDt <> "" and endDt <> "" then
		diff = datediff("d", startDt, endDt)
		
		for i=0 to diff			
			cWorkDt = dateadd("d",i,startDt)
			SQLTitle = "-- ■■■■ 공정 정보 관리 추가 ■■■■"
			subSQL = "exec spSaveOrderResult '" & lotNo & "', '" & lotYear & "', " & lotSubNo & ", '" & processCd & "', '" & working & "', '" & userId & "', '" & cWorkDt & "',  0, 0, '" & etc & "',  " & rank & ", '', '" & execTime & "'"
		
			If xMode="debug" Then 
				Call showDebug(SQLTitle,subSQL) 
			End If 
		
		'Response.write subSQL
		
			DbCon.Execute subSQL
		next
		'Response.end 
	end if 
	
	SQLTitle = "-- ■■■■ 공정 정보 관리 저장 ■■■■"
	SQL = "exec spSaveOrderResult '" & lotNo & "', '" & lotYear & "', " & lotSubNo & ", '" & processCd & "', '" & working & "', '" & userId & "', '" & workDt & "', " & goodQty & ", " & badQty & ", '" & etc & "', " & rank & ", '" & flag & "', '" & execTime & "'"

	If xMode="debug" Then 
		Call showDebug(SQLTitle,SQL) 
	End If 

'Response.write SQL
'Response.end
	DbCon.Execute SQL
	
	SQLTitle = "-- ■■■■ 공정 메모 저장 ■■■■"
	SQL = "exec spSaveOrderMemo '" & lotNo & "', '" & lotYear & "', " & lotSubNo & ", '" & processCd & "', " & rank & ", '" & orderMemo & "', '" & userId & "', '" & flag & "'"

	If xMode="debug" Then 
		Call showDebug(SQLTitle,SQL) 
	End If 

'Response.write SQL
'Response.end
	DbCon.Execute SQL	

	Call rsWithXML("Save OK!")
%>